﻿namespace Devonline.Entity;

/// <summary>
/// 认证用户, 字符主键的默认实现
/// </summary>
[Table("auth_user"), DisplayName("认证用户")]
public class AuthUser : AuthUser<string>, IIdentity, IEntitySet, IEntitySetWithCreate, IEntitySetWithCreateAndUpdate
{
    /// <summary>
    /// 通用附件集合, NotMapped Attachments 用于记录实体对象上上传的附件
    /// </summary>
    [NotMapped]
    public virtual ICollection<Attachment>? Attachments { get; set; }
}

/// <summary>
/// 认证用户
/// 认证信息和用户是一对一关系, 相互有字段指向, 但无外键直接关联
/// </summary>
[Table("auth_user"), DisplayName("认证用户")]
public class AuthUser<TKey> : Identity<TKey>, IIdentity<TKey>, IEntitySet<TKey>, IEntitySetWithCreate<TKey>, IEntitySetWithCreateAndUpdate<TKey> where TKey : IConvertible
{
    /// <summary>
    /// 认证方式
    /// </summary>
    [Column("auth_type", TypeName = "VARCHAR(16)"), DisplayName("认证方式"), Excel]
    public virtual AuthType AuthType { get; set; }
    /// <summary>
    /// 第三方认证编号, 对应比如微信的 OpenId
    /// </summary>
    [Column("open_id"), MaxLength(36), DisplayName("认证编号"), Excel]
    public virtual string? OpenId { get; set; }
    /// <summary>
    /// 是否已通过认证
    /// </summary>
    [Column("is_authed"), DisplayName("是否已认证"), Excel]
    public virtual bool IsAuthed { get; set; }
    /// <summary>
    /// 联系方式
    /// </summary>
    [Column("phone_number"), MaxLength(256), DisplayName("手机号码"), Excel]
    public virtual string? PhoneNumber { get; set; }
    /// <summary>
    /// 邮箱地址
    /// </summary>
    [Column("email"), MaxLength(256), DisplayName("邮箱"), Excel]
    public virtual string? Email { get; set; }
    /// <summary>
    /// 验证码
    /// </summary>
    [Column("verification_code"), MaxLength(16), DisplayName("验证码"), Excel]
    public virtual string? VerificationCode { get; set; }
    /// <summary>
    /// 验证码发送时间
    /// </summary>
    [Column("send_time"), DisplayName("验证码发送时间"), Excel]
    public virtual DateTime? SendTime { get; set; }
}
